using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MKDS_Course_Editor.BN_L
{
    public partial class BN_L : Form
    {
        public BN_L()
        {
            InitializeComponent();
        }

        private void BN_L_Load(object sender, EventArgs e)
        {

        }
    }
    public class LayerControl : TreeView
    {
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            Refresh();
        }
        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            Refresh();
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            /*int nr = 0;
            for (int i = 0; i < Nodes.Count; i++)
            {
                TreeNode n = Nodes[i];
                e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(214, 214, 214)), 0, nr * 33, 22, 32);
                e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 22, nr * 33, 22, nr * 33 + 32);
                e.Graphics.FillRectangle(new SolidBrush((n.IsSelected ? Color.FromArgb(51, 153, 255) : Color.FromArgb(214, 214, 214))), 23, nr * 33, 245, 32);
                e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 0, nr * 33 + 32, 245 + 23, nr * 33 + 32);
                nr++;
                if (n.IsExpanded)
                {
                    for (int j = 0; j < n.Nodes.Count; j++)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(214, 214, 214)), 0, nr * 33, 22, 32);
                        e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 22, nr * 33, 22, nr * 33 + 32);
                        e.Graphics.FillRectangle(new SolidBrush((n.IsSelected ? Color.FromArgb(51, 153, 255) : Color.FromArgb(214, 214, 214))), 23, nr * 33, 245, 32);
                        e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 0, nr * 33 + 32, 245 + 23, nr * 33 + 32);
                        //picture+15
                        nr++;
                    }
                }
            }*/
        }
        protected override bool DoubleBuffered
        {
            get
            {
                return true;
            }
            set
            {
                base.DoubleBuffered = value;
            }
        }
        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            //base.OnDrawNode(e);
            //Refresh();
            int nr = 0;
            for (int i = 0; i < Nodes.Count; i++)
            {
                TreeNode n = Nodes[i];
                if (n == e.Node)
                {
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(214, 214, 214)), 0, nr * 32, 22, 31);
                    e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 22, nr * 32, 22, nr * 32 + 32);
                    e.Graphics.FillRectangle(new SolidBrush((n.IsSelected ? Color.FromArgb(51, 153, 255) : Color.FromArgb(214, 214, 214))), 23, nr * 32, 245, 31);
                    e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 0, nr * 32 + 32, 245 + 23, nr * 32 + 32);
                    e.Graphics.DrawString(n.Text, new Font("Verdana", 10f, FontStyle.Bold), new SolidBrush((n.IsSelected ? Color.White : Color.Black)), 67, nr * 32 + 15);
                    break;
                }
                nr++;
                if (n.IsExpanded)
                {
                    for (int j = 0; j < n.Nodes.Count; j++)
                    {
                        TreeNode n2 = Nodes[i].Nodes[j];
                        if (n2 == e.Node)
                        {
                            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(214, 214, 214)), 0, nr * 32, 22, 31);
                            e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 22, nr * 32, 22, nr * 32 + 31);
                            e.Graphics.FillRectangle(new SolidBrush((n2.IsSelected ? Color.FromArgb(51, 153, 255) : Color.FromArgb(214, 214, 214))), 23, nr * 32, 245, 31);
                            e.Graphics.DrawLine(new Pen(Color.FromArgb(144, 144, 144)), 0, nr * 32 + 31, 245 + 23, nr * 32 + 31);
                            e.Graphics.DrawString(n2.Text, new Font("Verdana", 10f, FontStyle.Bold), new SolidBrush((n2.IsSelected ? Color.White : Color.Black)), 67 + 15, nr * 32+ 15);
                            break;
                        }
                        nr++;
                    }
                }
            }
        }
    }
}
